﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LEET.LEETCommon.Model;
using LEET.CommonInterfaces.Compilers;
using LEET.CommonInterfaces.TestControls;

namespace LEET.StandardModules.Instructions
{
    public class Target : Instruction
    {

        string target;
        bool focus;

        public Target(string [] args) : base(args)
        {
            target = args[1].Trim();
            focus = args.Length > 2;
        }

        public static IAutomationActionResult StaticCall()
        {
            //TODO
            return null;
        }

        public override String RenderStaticCall()
        {
            //TODO
            return "LEET.StandardModules.Instructions.Target.StaticCall()";
        }

        [Obsolete("This should now be replaced by RenderStaticCall", false)]
        protected override String RenderedMethodName(int i)
        {
            return "_" + i + "_TARGET" + "()";
        }

        [Obsolete("This should now be replaced by RenderStaticCall", false)]
        protected override String MethodBody(AssertionSet asserts)
        {
            List<System.Windows.Automation.AutomationElement> Boxes = new List<System.Windows.Automation.AutomationElement>();
            StringBuilder buf = new StringBuilder();
            buf.Append("                if(!Boxes.Contains(Box.RootElement))\r\n");
            buf.Append("                    Boxes.Add(Box.RootElement);\r\n");
            buf.Append("                return new AutomationActionResult(new TargetProcess(\"" + target + "\", " + focus.ToString().ToLower() + "));\r\n");
            return buf.ToString();
        }

        public override string PlainText()
        {
            return "Switched to recording " + target + ".";
        }
    }
}
